package com.moore.mapper;

import org.apache.ibatis.annotations.*;

@Mapper
public interface StarMapper {

    @Select("SELECT COUNT(*) > 0 FROM community_star WHERE community_id = #{communityId} AND candidate_id = #{candidateId}")
    boolean existsByCommunityIdAndCandidateId(@Param("communityId") Long communityId, @Param("candidateId") Long candidateId);

    @Insert("INSERT INTO community_star (community_id, candidate_id) VALUES (#{communityId}, #{candidateId})")
    int insert(@Param("communityId") Long communityId, @Param("candidateId") Long candidateId);

    @Delete("DELETE FROM community_star WHERE community_id = #{communityId} AND candidate_id = #{candidateId}")
    int deleteByCommunityIdAndCandidateId(@Param("communityId") Long communityId, @Param("candidateId") Long candidateId);

}